//
//  SSClassifyViewController.m
//  starspaceVR
//
//  Created by 曹端芹 on 17/9/12.
//  Copyright © 2017年 starspace. All rights reserved.
//

#import "SSClassifyViewController.h"
#import "SSContentViewController.h"
#import "SSVedioViewController.h"
#import "SSCustomSegmentView.h"
@interface SSClassifyViewController ()

@property (nonatomic,strong) SSContentViewController *contentVC;
@property (nonatomic,strong) SSVedioViewController *vedioVC;

@end

@implementation SSClassifyViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    [self setupItems];
}

- (void)setupItems {
    SSCustomSegmentView *segment = [[SSCustomSegmentView alloc] initWithItemTitles:@[@"内容",@"视频"]];
    self.navigationItem.titleView = segment;
    segment.frame = CGRectMake(0, 0, 130, 35);
    kWeakSelf(self, weakSelf);
    segment.SSCustomSegmentViewBtnClickHandle = ^(SSCustomSegmentView *segment, NSString *title, NSInteger currentIndex){
        [weakSelf changeChildVcWithCurrentIndex:currentIndex];
    };
    [segment clickDefault];

}

- (void)changeChildVcWithCurrentIndex:(NSInteger )currentIndex {
   
    BOOL isConten = (currentIndex == 0);
    if (isConten) {
        [self addClildVC:self.contentVC];
        [self removeClildVC:self.vedioVC];
    }else{
        [self addClildVC:self.vedioVC];
        [self removeClildVC:self.contentVC];
    }


}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

- (SSContentViewController *)contentVC {
    if (!_contentVC) {
        _contentVC = [[SSContentViewController alloc] init];
        
    }

    return _contentVC;
}

- (SSVedioViewController *)vedioVC {
    if (!_vedioVC) {
        _vedioVC = [[SSVedioViewController alloc] init];
    }
    return _vedioVC;

}

@end
